﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CNVP.JShop.UI;

namespace CNVP.JShop.Web.Admin.CommonWindows
{
    public partial class AjaxStandardValue : AdminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string Standard = Request.QueryString["Standard"];
            if (!string.IsNullOrEmpty(Standard))
            {
                string len = Request.QueryString["len"].ToString();
                string optionNull = "";
                string[] txtStandard = Standard.Split(Convert.ToChar(","));
                for (int i = 0; i < txtStandard.Length; i++)
                {
                    string ddlID = txtStandard[i].ToString();
                    string StandardType_Str = "";
                    var model_Standard = new BLL.CNVP_Standard().GetSingle_CNVP_StandardById(int.Parse(ddlID));
                    if (model_Standard != null)
                    {
                        StandardType_Str = model_Standard.StandardType.ToString();
                    }
                    if (StandardType_Str == "2")
                    {
                        optionNull += "<td>";
                        optionNull += "<img id=\"img" + ddlID + "" + len + "\" width=\"50\" height=\"50\" src=\"Images/noPhoto.gif\" onclick=\"showtopic(" + ddlID + ",'" + len + "')\" style =\"cursor:pointer;\" />";
                        optionNull += "<input id=\"text" + ddlID + "" + len + "\" type=\"hidden\" name=\"StandardValueID" + ddlID + "\" />";//注意：不管是图片，还文本框都是规格值‘StandardValueID’
                        optionNull += "</td>";
                    }
                    else
                    {
                        optionNull += "<td>";
                        optionNull += "<select id=\"ddl" + ddlID + "" + len + "\" name=\"StandardValueID" + ddlID + "\" >";
                        optionNull += "<option value=\"0\">请选择</option>";
                        var list_StandardValue = new BLL.CNVP_StandardValue().GetAll_CNVP_StandardValue(int.Parse(ddlID));
                        for (int j = 0; j < list_StandardValue.Count; j++)
                        {
                            optionNull += " <option value=\"" + list_StandardValue[j].ID + "\">" + list_StandardValue[j].StandardValueName + "</option>";
                        }
                        optionNull += "</select>";
                        optionNull += "</td>";
                    }
                }
                Response.Write(optionNull);
            }
        }
    }
}